<?php

class LoginController extends Vakanz_CRM_Controller_Action
{

    public function indexAction()
    {

    }
    public function loginAction() {
    	if ($this->_getParam('username') != 'vakanz' || $this->_getParam('password') != 'bemiddel') {
    		$this->view->errorMsg = 'Gebruikersnaam en/of wachtwoord zijn onjuist.';
    		$this->_forward('index','login','default');
    	} else {
			$crm = new Zend_Session_Namespace('CRM_Login');
			$crm->loginStatus = 4;
    		
			if (!empty($crm->lastpage_visited) && !preg_match('/\/?login/',$crm->lastpage_visited)) {
				$this->_redirect($crm->lastpage_visited);
			} else {
				$this->_redirect('/');
			}
    	}

    }
    public function logoutAction() {
    	$crm = new Zend_Session_Namespace('CRM_Login');
    	foreach ($crm as $key => $property) {
    		if ($propery != 'lastpage_visited') {
    			unset($crm->{$key});
    		}
    	}
    	$this->_redirect('/login');
    }
}
